﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Profile;
using System.IO;
using System.Text;

using Gift.DAL;
using Gift.Model;

namespace WebSite.admin.product
{
    public partial class goods_add03 : BaseAdmin
    {

        readonly DALGoods theGoods = new DALGoods();
        tbGoods oGoods;


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.BuildForm();
            }
        }



        void BuildForm()
        {

            if (Request.QueryString["gid"] != null)
            {
                oGoods = theGoods.GetModel(int.Parse(Request.QueryString["gid"]));
                this.isRush.Checked = oGoods.isRush;
                this.txtRushPoints.Text = oGoods.rushPoints.ToString();
                this.dpkStartTime.Text = oGoods.rushTimeFrom == null ? "" : string.Format("{0:yyyy-MM-dd}", oGoods.rushTimeFrom);
                this.dpkEndTime.Text = oGoods.rushTimeTo == null ? "" : string.Format("{0:yyyy-MM-dd}", oGoods.rushTimeTo);
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            if (Request.QueryString["gid"] != null)
            {
                oGoods = theGoods.GetModel(int.Parse(Request.QueryString["gid"]));
                oGoods.isRush = this.isRush.Checked;
                oGoods.rushPoints = int.Parse(this.txtRushPoints.Text);
                oGoods.rushTimeFrom = DateTime.Parse(this.dpkStartTime.Text);
                oGoods.rushTimeTo = DateTime.Parse(this.dpkEndTime.Text);
                theGoods.Update(oGoods);
                ExtAspNet.Alert.Show("保存成功！");
            }
            else
            {
                ExtAspNet.Alert.Show("请选添加商品！");
 
            }
        }


    }
}